package com.quick.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.quick.common.annotation.Log;
import com.quick.common.core.controller.BaseController;
import com.quick.common.core.domain.AjaxResult;
import com.quick.common.enums.BusinessType;
import com.quick.system.domain.DutyRoom;
import com.quick.system.service.IDutyRoomService;
import com.quick.common.utils.poi.ExcelUtil;
import com.quick.common.core.page.TableDataInfo;

/**
 * 值班室Controller
 * 
 * @author quick
 * @date 2025-01-03
 */
@RestController
@RequestMapping("/server/room")
public class DutyRoomController extends BaseController
{
    @Autowired
    private IDutyRoomService dutyRoomService;

    /**
     * 查询值班室列表
     */
    @PreAuthorize("@ss.hasPermi('server:room:list')")
    @GetMapping("/list")
    public TableDataInfo list(DutyRoom dutyRoom)
    {
        startPage();
        List<DutyRoom> list = dutyRoomService.selectDutyRoomList(dutyRoom);
        return getDataTable(list);
    }

    /**
     * 导出值班室列表
     */
    @PreAuthorize("@ss.hasPermi('server:room:export')")
    @Log(title = "值班室", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DutyRoom dutyRoom)
    {
        List<DutyRoom> list = dutyRoomService.selectDutyRoomList(dutyRoom);
        ExcelUtil<DutyRoom> util = new ExcelUtil<DutyRoom>(DutyRoom.class);
        util.exportExcel(response, list, "值班室数据");
    }

    /**
     * 获取值班室详细信息
     */
    @PreAuthorize("@ss.hasPermi('server:room:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dutyRoomService.selectDutyRoomById(id));
    }

    /**
     * 新增值班室
     */
    @PreAuthorize("@ss.hasPermi('server:room:add')")
    @Log(title = "值班室", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DutyRoom dutyRoom)
    {
        return toAjax(dutyRoomService.insertDutyRoom(dutyRoom));
    }

    /**
     * 修改值班室
     */
    @PreAuthorize("@ss.hasPermi('server:room:edit')")
    @Log(title = "值班室", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DutyRoom dutyRoom)
    {
        return toAjax(dutyRoomService.updateDutyRoom(dutyRoom));
    }

    /**
     * 删除值班室
     */
    @PreAuthorize("@ss.hasPermi('server:room:remove')")
    @Log(title = "值班室", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dutyRoomService.deleteDutyRoomByIds(ids));
    }
}
